<?

class Admin_Comments extends MY_Controller {

    function Admin_Comments() {

        parent::MY_Controller(TRUE);

    }

    function index() {

        $this->mdl_sessions->set_last_index();

        $this->load->view('admin/comments_index');

    }

    function form() {

        if ($this->mdl_comments->validate()) {

            $this->mdl_comments->save();

            redirect('admin_comments/index');

        }

        else {

            if (!$_POST and $this->uri_assoc('comment_id')) {

                $this->mdl_comments->prep_validation($this->mdl_comments->get(array('comment_id'=>$this->uri_assoc('comment_id'))));

            }

            $this->load->view('admin/comments_form');

        }

    }

    function delete() {

        $this->mdl_comments->delete();

        redirect($this->session->userdata('last_index'));

    }

}

?>